package com.example.patternfactory0307.controller;

import com.example.patternfactory0307.abstractone.One;
import com.example.patternfactory0307.abstractone.Three;
import com.example.patternfactory0307.abstractone.Tow;
import com.example.patternfactory0307.strategy.ActionLogStrategy;
import com.example.patternfactory0307.strategy.ActionLogStrategyHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Created by huanglijun on 2019/3/7
 */
@RestController
public class HelloController {

    @Autowired
    private ActionLogStrategyHolder actionLogStrategyHolder;

    @Autowired
    private One one;
    @Autowired
    private Tow tow;
    @Autowired
    private Three three;

    @GetMapping(value = "/test")
    public Object test(){
        ActionLogStrategy questionStrategy = actionLogStrategyHolder.getBy("QuestionStrategy");
        if (questionStrategy != null){
            System.out.println("hello world");
        }
        return "ok";
    }


    @GetMapping(value = "/one")
    public Object one(){
        one.execute("one");
        return "one";
    }

    @GetMapping(value = "/two")
    public Object two(){
        tow.execute("two");
        return "two";
    }

    @GetMapping(value = "/three")
    public Object three(){
        three.execute("three");
        return "three";
    }
}
